package uk.co.agileworks.bidpirate.web;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;

import uk.co.agileworks.bidpirate.model.User;

@Component
public class UserValidator implements Validator<User> {

	@Override
	public boolean validate(User user, Errors errors) {
		
		if (user.getUsername().isEmpty()) {
			errors.reject("username.empty");
		}
		if (user.getPassword().isEmpty()) {
			errors.reject("password.empty");
		}
		return !errors.hasErrors();
	}

}
